import request from '@/utils/request'

export function addProject(data) {
  return request({
    url: 'api/project',
    method: 'post',
    data
  })
}

export function getBooks(params) {
  return request({
    url: 'api/book',
    method: 'get',
    params
  })
}
export function downBook(data) {
  return request({
    url: 'api/book/download',
    method: 'POST',
    data
  })
}
export function editBanners(data) {
  return request({
    url: 'api/banner',
    method: 'put',
    data
  })
}
export function deleteBanners(data) {
  return request({
    url: 'api/banner',
    method: 'delete',
    data
  })
}

export function getMenuSuperior(ids) {
  const data = Array.isArray(ids) || ids.length === 0 ? ids : Array.of(ids)
  return request({
    url: 'api/menus/superior',
    method: 'post',
    data
  })
}

export function getChild(id) {
  return request({
    url: 'api/menus/child?id=' + id,
    method: 'get'
  })
}

export function buildMenus() {
  return request({
    url: 'api/menus/build',
    method: 'get'
  })
}

export function addPaint(data) {
  return request({
    url: 'api/banner',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'api/banner',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'api/menus',
    method: 'put',
    data
  })
}

export default { addPaint, downBook, editBanners, edit, del, addProject, getMenuSuperior, getBooks, getChild }
